package org.footito.android.ui.views;

import org.footito.android.R;
import org.footito.android.data.Status;

import android.content.Context;
import android.text.Html;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

public class TimelineRow extends FrameLayout{

	private View layoutDisplayed;
	private TextView tv_status;
	private ImageView iv_flag;
	private CounterView counterView;

	public TimelineRow(Context context) {
		super(context);
		createView(context);
	}

	public TimelineRow(Context context, AttributeSet attrs) {
		super(context, attrs);
		createView(context);
	}

	public TimelineRow(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		createView(context);
	}

	private void createView(Context context) {
		LayoutInflater.from(context).inflate(R.layout.row_timeline, this);
		layoutDisplayed = findViewById(R.id.layoutDisplayed);
		tv_status = (TextView) findViewById(R.id.TV_Team_Status);
		iv_flag = (ImageView) findViewById(R.id.IV_Flag);
		counterView = (CounterView) findViewById(R.id.counterView);
	}

	public void setStatus(Status status) {
		tv_status.setText(status.getContent());
		tv_status.setText(Html.fromHtml("<b>" + status.getTeam().getName()
				+ "</b> : " + status.getContent()));
		iv_flag.setImageBitmap(status.getTeam().getPicture(getContext()));
		counterView.setCounter(status.getComments().size());
	}


}
